package com.example.demo.controller;

import com.example.demo.common.Response;
import com.example.demo.pojo.RequestUserPoJo;
import com.example.demo.service.UserService;
import net.minidev.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

/**
 * @author T480
 */
@RestController
@RequestMapping(value = "/user")
public class UserController {

            @Autowired
            private UserService userService;

            /**
             * 根据传入的对象进行内容新增或修改
             * @param requestUserPoJo
             * @return
             */
            @RequestMapping(value = "/inserOrUpdate/user")
            public Response inserOrUpdateUser(@RequestBody RequestUserPoJo requestUserPoJo){

                Response response = userService.inserOrUpdateUser(requestUserPoJo);
                return response;
         }


            /**
             * 根据用户Id进行用户删除-逻辑删除
             * @param list
             * @return
             */
            @RequestMapping(value = "/deleteByUserId/user")
            public Response deleteByUserId(@RequestBody List<String> list){

                Response response = userService.deleteByUserId(list);
                return response;
            }

            /**
             * 用户列表信息分页查询
             * @param requestUserPoJo
             * @return
             */
            @RequestMapping(value = "/selectPageUser/user")
            public Response selectPageUser(@RequestBody RequestUserPoJo requestUserPoJo){

                Response response = userService.selectPageUser(requestUserPoJo);
                return response;
            }
}
